package cn.edu.wynu.d12_api_object;
// Cloneable是一个标记接口，可以认为是一种规则，它没有任何方法
public class User implements Cloneable{
    private int id; // 编号
    private String name; // 用户名
    private String password; // 密码
    private double[] scores; // 分数

    public User() {
    }

    public User(int id, String name, String password, double[] scores) {
        this.id = id;
        this.name = name;
        this.password = password;
        this.scores = scores;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        // super去调用父类Object中的clone方法
        // u2实现了浅克隆
        return super.clone();

        // u2实现了深克隆
//        User u2 = (User) super.clone();
//        u2.scores = u2.scores.clone();
//        return u2; // u2实现了深克隆
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public double[] getScores() {
        return scores;
    }

    public void setScores(double[] scores) {
        this.scores = scores;
    }
}
